package com.bole.controller;

import com.bole.data.Result;
import com.bole.dto.user.UserDto;
import com.bole.feign.CarFeign;
import org.apache.shiro.SecurityUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("car")
public class CarController {

    @Resource
    private CarFeign carFeign;

    @GetMapping("/findCarByUserId")
    public Result findCarByUserId() {
        UserDto userDto = (UserDto) SecurityUtils.getSubject().getPrincipal();
        Long userId = userDto.getId();
        Result result = carFeign.getCarByUserId(userId);
        return result;
    }

    @DeleteMapping("/revoke/{carId}")
    public Result revoke(@PathVariable("carId") Long carId) {
        Result result = carFeign.revoke(carId);
        return result;
    }
}
